






//food generation
module FOOD_Gen(

	input		clk,
	input		rst,
	
	input[5:0]	seedx,
	input[4:0]	seedy,
	
	input		eated,
	
	output[5:0]	foodx,
	output[4:0] foody

);

reg[5:0] randx;
reg[4:0] randy;


assign foodx = (randx >= 'd60) ? 'd59 : randx;
assign foody = randy;

always@(posedge clk or negedge rst)
begin
	if(rst == 1'b0)
		randx <= seedx;
	else if(eated)
	begin
	randx[0] <= randx[5];
	randx[1] <= randx[0];
	randx[2] <= randx[1] ^ randx[5] ;
	randx[3] <= randx[2] ^ randx[5];
	randx[4] <= randx[3] ^ randx[5];
	randx[5] <= randx[4];
	end
	else
		randx <= randx;
end


always@(posedge clk or negedge rst)
begin
	if(rst == 1'b0)
		randy <= seedy;
	else if(eated)
	begin
	randy[0] <= randy[4];
	randy[1] <= randy[0]^ randy[4];
	randy[2] <= randy[1] ^ randy[4] ;
	randy[3] <= randy[2] ^ randy[4];
	randy[4] <= randy[3];
	end
	else
		randy <= randy;
end




endmodule